package com.mytest;

import java.math.BigDecimal;

import net.sf.json.JSONObject;

public class JavaTest {

	/**
	 * 奇偶数取余
	 * @param i
	 * @return
	 */
	public static void isOdd(){
		System.out.println("1.奇偶数取余测试：" + (-3 % 2 == 1));
	}

	/**
	 * double 计算精度丢失问题，（计算机2进制表示十进制会出现进度丢失问题去估值）
	 */
	public static void doubleOperation(){
	
		System.out.println("\n.double计算:" + (2.00 - 1.10));
		System.out.println("bigDecimal计算：" + new BigDecimal(2.00 + "").subtract(new BigDecimal(1.10 + "")).doubleValue());
	}
	
	/**
	 * long 运算过程中，精度丢失
	 */
	public static void longOperation(){
		final long MICROS_PER_DAY = 24 * 60 * 60 * 1000 * 1000;
		final long MILLIS_PER_DAY = 24 * 60 * 60 * 1000;
		System.out.println("\n3.int Max value: " + Integer.MAX_VALUE);
		System.out.println("long Max value: " + Long.MAX_VALUE);
		System.out.println("MICROS_PER_DAY: " + MICROS_PER_DAY);
		System.out.println("MILLIS_PER_DAY: " + MILLIS_PER_DAY);
		System.out.println("x / y : " + (MICROS_PER_DAY / MILLIS_PER_DAY));
	}
	
	public static void intAdd(){
		System.out.println("\n4.");
	}
	
	public static void joyOfHex(){
		System.out.println("\n5.十六进制趣事：");
		System.out.print(0x100000000L + " + " + 0xcafebabe + " = ");
		System.out.println(Long.toHexString(0x100000000L + 0xcafebabe));
		System.out.print(Long.toHexString(0x100000000L) + " + " + Long.toHexString(0xcafebabe) + " = ");
		System.out.println(Long.toHexString(0x100000000L + 0xcafebabe));
		
	}
	
	public static void  multicast(){
		System.out.println("\n6.多重转型：");
		System.out.println(-1);
		System.out.println((byte)-1);
		System.out.println((char)(byte)-1);
		System.out.println((int)(char)(byte)-1);
	}
	
	
	public static void main(String[] args) {
		multicast();
	}

}
